<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/templates/template.xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:nu="http://nu.jcperera.homeip.net/facelets" xmlns:p="http://primefaces.org/ui">

	<ui:param name="title" value="NU Application Edit Web Info Site Page" />

	<f:metadata>
		<f:viewParam name="parentid" value="#{webInfoValueBean.parentid}"></f:viewParam>
		<f:viewParam name="entityid" value="#{webInfoValueBean.entityid}"></f:viewParam>
	</f:metadata>

	<ui:define name="body">
		<p:outputPanel>
			<p:messages id="edit-messages" autoUpdate="true" closable="true" showDetail="true" redisplay="no" />

			<p:panel id="parent-2-panel" header="Parent Web Info Site" style="margin-bottom:10px;">
				<h:panelGrid columns="2">
					<h:outputLabel for="parent-2-entityid" value="ID: " />
					<p:inputText id="parent-2-entityid" value="#{webInfoValueBean.pattern.site.entityid}" required="false" label="ID"
						size="45" readonly="true" disabled="true" />

					<h:outputLabel for="parent-2-url" value="URL: *" />
					<p:inputText id="parent-2-url" value="#{webInfoValueBean.pattern.site.url}" required="true" label="URL" size="150"
						readonly="true" disabled="true" />

					<h:outputLabel for="parent-2-parameters" value="Parameters: *" />
					<p:inputText id="parent-2-parameters" value="#{webInfoValueBean.pattern.site.parameters}" required="true"
						label="Parameters" size="100" readonly="true" disabled="true" />
				</h:panelGrid>
			</p:panel>

			<p:panel id="parent-1-panel" header="Parent Web Info Pattern" style="margin-bottom:10px;">
				<h:panelGrid columns="2">
					<h:outputLabel for="parent-1-entityid" value="ID: " />
					<p:inputText id="parent-1-entityid" value="#{webInfoValueBean.pattern.entityid}" required="false" label="ID"
						size="45" readonly="true" disabled="true" />

					<h:outputLabel for="parent-1-xslPattern" value="XSL Pattern: *" />
					<p:inputText id="parent-1-xslPattern" value="#{webInfoValueBean.pattern.xslPattern}" required="true"
						label="XSL Pattern" size="150" readonly="true" disabled="true" />

					<h:outputLabel for="parent-2-format" value="Format: *" />
					<p:inputText id="parent-2-format" value="#{webInfoValueBean.pattern.format}" required="true" label="Format"
						size="100" readonly="true" disabled="true" />

					<h:outputLabel for="parent-1-fieldName" value="Field Name: *" />
					<p:inputText id="parent-1-fieldName" value="#{webInfoValueBean.pattern.fieldName}" required="true"
						label="Field Name" size="30" readonly="true" disabled="true" />

					<h:outputLabel for="parent-1-isPrimary" value="Is Primary: *" />
					<p:selectBooleanButton id="parent-1-isPrimary" value="#{webInfoValueBean.pattern.isPrimary}" onLabel="Yes"
						offLabel="No" onIcon="ui-icon-check" offIcon="ui-icon-close" readonly="true" disabled="true" />
				</h:panelGrid>
			</p:panel>

			<p:panel id="edit-panel" header="Create new Web Info Value" style="margin-bottom:10px;">
				<h:panelGrid columns="3" style="margin-bottom:10px;">
					<h:outputLabel for="entityid" value="ID: " />
					<p:inputText id="entityid" value="#{webInfoValueBean.entityid}" required="false" label="ID" size="45"
						readonly="true" disabled="true" />
					<p:message for="entityid" />

					<h:outputLabel for="matchingRegex" value="Matching Regex: *" />
					<p:inputText id="matchingRegex" value="#{webInfoValueBean.matchingRegex}" required="true" label="Matching Regex"
						size="150">
						<f:validateLength minimum="15" />
					</p:inputText>
					<p:message for="matchingRegex" />

					<h:outputLabel for="followUpEnabled" value="Follow-up enabled: *" />
					<p:selectBooleanButton id="followUpEnabled" value="#{webInfoValueBean.followUpEnabled}" onLabel="Yes" offLabel="No"
						onIcon="ui-icon-check" offIcon="ui-icon-close" />
					<p:message for="followUpEnabled" />

					<h:outputLabel for="pendingCheck" value="Pending check: *" />
					<p:selectBooleanButton id="pendingCheck" value="#{webInfoValueBean.pendingCheck}" onLabel="Yes" offLabel="No"
						onIcon="ui-icon-check" offIcon="ui-icon-close" />
					<p:message for="pendingCheck" />
				</h:panelGrid>

				<p:commandButton value="Save" actionListener="#{webInfoValueBean.saveWebInfoValue}" id="saveButton"
					icon="ui-icon-disk" update="edit-panel,edit-messages"></p:commandButton>

				<p:commandButton value="Delete" id="deleteButton" onclick="confirmation.show()" icon="ui-icon-trash" type="button">
				</p:commandButton>

				<p:button value="Go to parent" outcome="/pages/webinfopattern/edit.xhtml?faces-redirect=true" process="@this">
					<f:param name="entityid" value="#{webInfoValueBean.parentid}" />
				</p:button>

				<p:confirmDialog header="Confirmation" message="Are you sure you want to delete the entity?"
					widgetVar="confirmation" severity="alert" closeOnEscape="true" appendToBody="true">
					<p:commandButton value="Yes" icon="ui-icon-check" action="#{webInfoValueBean.deleteWebInfoValue}" />
					<p:commandButton value="No" icon="ui-icon-close" onclick="confirmation.hide()" type="button" />
				</p:confirmDialog>
			</p:panel>

		</p:outputPanel>
	</ui:define>
</ui:composition>